/********************************************************************************
    Copyright (C) Binod Nepal, Planet Earth Solutions Pvt. Ltd., Kathmandu.
	Released under the terms of the GNU General Public License, GPL, 
	as published by the Free Software Foundation, either version 3 
	of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************************/

CREATE PROCEDURE dbo.CreateCategoryForm
	@CategoryId integer
AS
BEGIN
	SET NOCOUNT ON;
	DECLARE @IsWarrantyApplicable bit;
	DECLARE @IsUsed bit;
	
	SELECT @IsWarrantyApplicable=IsWarrantyApplicable, @IsUsed=IsUsed
	FROM dbo.Categories
	WHERE CategoryId=@CategoryId;

	
	IF(@IsWarrantyApplicable = 1)
	BEGIN
		IF(@IsUsed=0)
		BEGIN
			IF NOT EXISTS(SELECT TOP 1 1 FROM dbo.CustomFields WHERE CategoryId=@CategoryId AND FieldLabel='Warranty Type')
			BEGIN
				INSERT INTO dbo.CustomFields(CategoryId, FieldOrder, FieldStatus, Note, FieldLabel, FieldTypeName, MaxLength, MaxValue, List, FieldRequired, CssClass, InitialValue, IsExpression, RegularExpression)
				SELECT @CategoryId, 5000, 1, 'Please choose the best option that applies to your item.', 'Warranty Type', 'RadioButton List',-1, -1, 'New-Includes Warranty, New-No Warranty, Refurbished-Includes Warranty, Refurbished-No Warranty', 1, '', 'New-Box Packed', 0, '';
			END;
						
			IF NOT EXISTS(SELECT TOP 1 1 FROM dbo.CustomFields WHERE CategoryId=@CategoryId AND FieldLabel='Total Warranty Period')
			BEGIN
				INSERT INTO dbo.CustomFields(CategoryId, FieldOrder, FieldStatus, Note, FieldLabel, FieldTypeName, MaxLength, MaxValue, List, FieldRequired, CssClass, InitialValue, IsExpression, RegularExpression)
				SELECT @CategoryId, 5001, 1, 'Please tell us the total warranty period in months.', 'Total Warranty Period', 'Integer', 2, -1, '', 0, 'textbox', '', 0, '';
			END;
		END;
		ELSE
		BEGIN
			IF NOT EXISTS(SELECT TOP 1 1 FROM dbo.CustomFields WHERE CategoryId=@CategoryId AND FieldLabel='Item Condition')
			BEGIN
				INSERT INTO dbo.CustomFields(CategoryId, FieldOrder, FieldStatus, Note, FieldLabel, FieldTypeName, MaxLength, MaxValue, List, FieldRequired, CssClass, InitialValue, IsExpression, RegularExpression)
				SELECT @CategoryId, 5002, 1, 'Please choose the best option that applies to your item.', 'Item Condition', 'RadioButton List',-1, -1, 'Used-No Warranty, Used-With Warranty, Old-For Parts Not Working, Old-Damaged', 1, '', 'New-Box Packed', 0, '';
			END;

			IF NOT EXISTS(SELECT TOP 1 1 FROM dbo.CustomFields WHERE CategoryId=@CategoryId AND FieldLabel='Remaining Warranty Period')
			BEGIN
				INSERT INTO dbo.CustomFields(CategoryId, FieldOrder, FieldStatus, Note, FieldLabel, FieldTypeName, MaxLength, MaxValue, List, FieldRequired, CssClass, InitialValue, IsExpression, RegularExpression)
				SELECT @CategoryId, 5003, 1, 'Please tell us the remaining warranty period in months.', 'Remaining Warranty Period', 'Integer', 2, -1, '', 0, 'textbox', '', 0, '';		
			END;
		END;
	END;
	
	IF(@IsUsed=1)
	BEGIN
		IF NOT EXISTS(SELECT TOP 1 1 FROM dbo.CustomFields WHERE CategoryId=@CategoryId AND FieldLabel='Used Months')
		BEGIN
			INSERT INTO dbo.CustomFields(CategoryId, FieldOrder, FieldStatus, Note, FieldLabel, FieldTypeName, MaxLength, MaxValue, List, FieldRequired, CssClass, InitialValue, IsExpression, RegularExpression)
			SELECT @CategoryId, 5004, 1, '(Used) Please tell us for how many months have you used this item.', 'Used Months', 'Integer', 2, -1, '', 0, 'textbox', '', 0, '';	
		END;
	END;

	IF NOT EXISTS(SELECT TOP 1 1 FROM dbo.CustomFields WHERE CategoryId=@CategoryId AND FieldLabel='URL to Read More About This Item')
	BEGIN
		INSERT INTO dbo.CustomFields(CategoryId, FieldOrder, FieldStatus, Note, FieldLabel, FieldTypeName, MaxLength, MaxValue, List, FieldRequired, CssClass, InitialValue, IsExpression, RegularExpression)
		SELECT @CategoryId, 5005, 1, 'Provide a link to website containing more information on this item. Please note that a link failing to resolve will be ignored.', 'URL to Read More About This Item', 'url', 332, -1, '', 0, 'textbox wide', '', 0, '';
	END;
	
	RETURN 1;	
END;

GO


INSERT INTO dbo.Cities
SELECT 'Kathmandu' UNION ALL
SELECT 'Pokhara' UNION ALL
SELECT 'Narayangadh' UNION ALL
SELECT 'Hetauda' UNION ALL
SELECT 'Birgunj' UNION ALL
SELECT 'Biratngar' UNION ALL
SELECT 'Nepalgunj' UNION ALL
SELECT 'Others';

GO

INSERT INTO dbo.Categories(CategoryName, AllowEntry)
SELECT 'Apparels & Jewelry', 0 UNION ALL
SELECT 'Vehicles', 0 UNION ALL
SELECT 'Real Estate', 0 UNION ALL
SELECT 'Computers & Laptops', 0 UNION ALL
SELECT 'Tablets & Phones', 0 UNION ALL
SELECT 'Electronic Equipment', 0 UNION ALL
SELECT 'Musical Instruments', 0 UNION ALL
SELECT 'Entertainment & Leisure', 0 UNION ALL
SELECT 'Services', 0 UNION ALL
SELECT 'Professional', 0 UNION ALL
SELECT 'Training', 1 UNION ALL
SELECT 'Furnitures & Interior', 1 UNION ALL
SELECT 'Home & Garden', 1 UNION ALL
SELECT 'Pets & Livestock', 1 UNION ALL
SELECT 'Software', 1 UNION ALL
SELECT 'Sports', 0 UNION ALL
SELECT 'Others', 0;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Software');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Accounting Software', 1 UNION ALL
SELECT @Parent, 'CRM & ERP Solutions', 1 UNION ALL
SELECT @Parent, 'Business Software', 1 UNION ALL
SELECT @Parent, 'Operating Systems', 1 UNION ALL
SELECT @Parent, 'Office & Production', 1 UNION ALL
SELECT @Parent, 'Enterprise Solutions', 1 UNION ALL
SELECT @Parent, 'Games', 1 UNION ALL
SELECT @Parent, 'Web Applications', 1 UNION ALL
SELECT @Parent, 'Software Wanted', 1 UNION ALL
SELECT @Parent, 'Software, Others', 1;

GO
DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Entertainment & Leisure');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Music', 1 UNION ALL
SELECT @Parent, 'Movies', 1 UNION ALL
SELECT @Parent, 'Tickets', 1 UNION ALL
SELECT @Parent, 'CD/DVD', 1 UNION ALL
SELECT @Parent, 'Theatre', 1 UNION ALL
SELECT @Parent, 'Camping, Rafting, & Bungy', 1 UNION ALL
SELECT @Parent, 'Cycling & Biking', 1 UNION ALL
SELECT @Parent, 'Vacation', 1 UNION ALL
SELECT @Parent, 'Dance Party', 1 UNION ALL
SELECT @Parent, 'Restaurants', 1 UNION ALL
SELECT @Parent, 'Entertainment, Others', 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Apparels & Jewelry');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Apparels', 1 UNION ALL
SELECT @Parent, 'Athletic Wear', 1 UNION ALL
SELECT @Parent, 'Bags & Luggage', 1 UNION ALL
SELECT @Parent, 'Men''s Clothing', 1 UNION ALL
SELECT @Parent, 'Men''s Accessories', 1 UNION ALL
SELECT @Parent, 'Women''s Clothing', 1 UNION ALL
SELECT @Parent, 'Women''s Accessories', 1 UNION ALL
SELECT @Parent, 'Child Clothing', 1 UNION ALL
SELECT @Parent, 'Child Accessories', 1 UNION ALL
SELECT @Parent, 'Fashion Accessories', 1 UNION ALL
SELECT @Parent, 'Shoes', 1 UNION ALL
SELECT @Parent, 'Jewelry', 1 UNION ALL
SELECT @Parent, 'Gift Items', 1 UNION ALL
SELECT @Parent, 'Purses & Wallets', 1 UNION ALL
SELECT @Parent, 'Watches & Timepieces', 1 UNION ALL
SELECT @Parent, 'Related Services', 1 UNION ALL
SELECT @Parent, 'Beauty Products & Services', 1 UNION ALL
SELECT @Parent, 'Dolls & Toys', 1 UNION ALL
SELECT @Parent, 'Perfumes & Fragrances', 1 UNION ALL
SELECT @Parent, 'Apparels, Others', 1;

GO
DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Tablets & Phones');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed, IsWarrantyApplicable)
SELECT @Parent, 'Mobile Phones (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Mobile Phones (Used)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Mobile Phones (Accessories)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Smartphones (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Smartphones (Used)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Smartphones (Accessories)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Tablets (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Tablets (Used)', 1, 1, 1  UNION ALL
SELECT @Parent, 'Tablets (Accessories)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Tablets & Phones, Others', 1, 0, 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Computers & Laptops');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed, IsWarrantyApplicable)
SELECT @Parent, 'Assembled Computers (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Assembled Computers (Used)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Assembled Computers (Accessories)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Branded Computers (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Branded Computers (Accessories)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Laptops (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Laptops (Used)', 1, 1, 1  UNION ALL
SELECT @Parent, 'Laptops (Accessories)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Annual Maintenance Contract (AMC)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Computers, Others', 1, 0, 0;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Electronic Equipment');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed, IsWarrantyApplicable)
SELECT @Parent, 'Cameras (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Cameras (Old)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Camera Accessories (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Camera Accessories (Old)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Televisions (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Televisions (Old)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Home Electronic Appliances (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Home Electronic Appliances (Old)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Other Electronic Appliances (New)', 1, 0, 1 UNION ALL
SELECT @Parent, 'Other Electronic Appliances (Old)', 1, 1, 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Vehicles');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed, IsWarrantyApplicable)
SELECT @Parent, 'Cars, Hatchbacks (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Cars, Hatchbacks (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Cars, Sedans (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Cars, Sedans (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Cars, SUVs/MUVs (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Cars, SUVs/MUVs (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Cars, Parts & Accessories', 1, 0, 1 UNION ALL
SELECT @Parent, 'Motorbikes (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Motorbikes (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Motorbikes, Parts & Accessories', 1, 0, 1 UNION ALL
SELECT @Parent, 'Buses & Vans (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Buses & Vans (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Trucks (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Trucks (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Tractors (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Tractors (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Cranes & Utility Vehicles', 1, 0, 0 UNION ALL
SELECT @Parent, 'Vehicles, Others (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Vehicles, Others (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Vehicles, Parts & Accessories', 1, 0, 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Musical Instruments');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed, IsWarrantyApplicable)
SELECT @Parent, 'Guitars (New)', 1, 0, 0 UNION ALL
SELECT @Parent, 'Guitars (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Violin (New)', 1, 0, 0  UNION ALL
SELECT @Parent, 'Violin (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Pianos, Synthesizers, & Keyboards (New)', 1, 0, 1  UNION ALL
SELECT @Parent, 'Pianos, Synthesizers, & Keyboards (Old)', 1, 1, 1 UNION ALL
SELECT @Parent, 'Drums Set (New)', 1, 0, 0  UNION ALL
SELECT @Parent, 'Drums Set (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Nepali Musical Instruments (New)', 1, 0, 0  UNION ALL
SELECT @Parent, 'Nepali Musical Instruments (Old)', 1, 1, 0 UNION ALL
SELECT @Parent, 'Musical Instruments, Others (New)', 1, 0, 0  UNION ALL
SELECT @Parent, 'Musical Instruments, Others (Old)', 1, 1, 0;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Real Estate');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed)
SELECT @Parent, 'Land (Sale)', 1, 0 UNION ALL
SELECT @Parent, 'Land (Lease)', 1, 0 UNION ALL
SELECT @Parent, 'Houses (Sale)', 1, 1 UNION ALL
SELECT @Parent, 'Houses (Lease)', 1, 0 UNION ALL
SELECT @Parent, 'Apartments (Sale)', 1, 1 UNION ALL
SELECT @Parent, 'Apartments (Lease)', 1, 0 UNION ALL
SELECT @Parent, 'Parking Lot (Sale)', 1, 0 UNION ALL
SELECT @Parent, 'Parking Lot (Lease)', 1, 0 UNION ALL
SELECT @Parent, 'Commercial Space (Rent)', 1, 0 UNION ALL
SELECT @Parent, 'Commercial Space (Wanted on Rent)', 1, 0 UNION ALL
SELECT @Parent, 'Flat (Rent)', 1, 0 UNION ALL
SELECT @Parent, 'Flat (Wanted on Rent)', 1, 0 UNION ALL
SELECT @Parent, 'House (Rent)', 1, 0 UNION ALL
SELECT @Parent, 'House (Wanted on Rent)', 1, 0 UNION ALL
SELECT @Parent, 'Paying Guests', 1, 0 UNION ALL
SELECT @Parent, 'Girls'' Hostel', 1, 0 UNION ALL
SELECT @Parent, 'Boys'' Hostel', 1, 0 UNION ALL
SELECT @Parent, 'Roommate Wanted', 1, 0 UNION ALL
SELECT @Parent, 'Shared Rentals', 1, 0 UNION ALL
SELECT @Parent, 'Real Estate, Others', 1, 0;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Pets & Livestock');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Birds', 1 UNION ALL
SELECT @Parent, 'Cats', 1 UNION ALL
SELECT @Parent, 'Dogs', 1 UNION ALL
SELECT @Parent, 'Puppies', 1 UNION ALL
SELECT @Parent, 'Kittens', 1 UNION ALL
SELECT @Parent, 'Fish', 1 UNION ALL
SELECT @Parent, 'Horse', 1 UNION ALL
SELECT @Parent, 'Lost Pets', 1 UNION ALL
SELECT @Parent, 'Pet Care', 1 UNION ALL
SELECT @Parent, 'Pet Food', 1 UNION ALL
SELECT @Parent, 'Pet Health', 1 UNION ALL
SELECT @Parent, 'Animal Rescue (Adpotion)', 1 UNION ALL
SELECT @Parent, 'Pets (To Give or Donate)', 1 UNION ALL
SELECT @Parent, 'Lost & Found', 1 UNION ALL
SELECT @Parent, 'Pets & Livestock, Others', 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Furnitures & Interior');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed)
SELECT @Parent, 'Interior Works', 1, 0 UNION ALL
SELECT @Parent, 'Paintings & Wallpapers', 1, 0 UNION ALL
SELECT @Parent, 'Tables', 1, 0 UNION ALL
SELECT @Parent, 'Cabinets & Racks', 1, 0 UNION ALL
SELECT @Parent, 'Chairs', 1, 0 UNION ALL
SELECT @Parent, 'Floor & Ceiling', 1, 0 UNION ALL
SELECT @Parent, 'Bedroom Furniture', 1, 0 UNION ALL
SELECT @Parent, 'Furnishings', 1, 0 UNION ALL
SELECT @Parent, 'Baby Furniture', 1, 0 UNION ALL
SELECT @Parent, 'Home Furniture', 1, 0 UNION ALL
SELECT @Parent, 'Bathroom Furniture', 1, 0 UNION ALL
SELECT @Parent, 'LED/LCD Displays', 1, 0 UNION ALL
SELECT @Parent, 'Office Furniture', 1, 0 UNION ALL
SELECT @Parent, 'Furniture on Sell (Used)', 1, 1 UNION ALL
SELECT @Parent, 'Furnitures, Others', 1, 0;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Others');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Shop to Sell', 1 UNION ALL
SELECT @Parent, 'Business to Sell', 1 UNION ALL
SELECT @Parent, 'Business Opportunity', 1 UNION ALL
SELECT @Parent, 'Books & Magazines', 1 UNION ALL
SELECT @Parent, 'Car Rental', 1 UNION ALL
SELECT @Parent, 'Collectibles', 1 UNION ALL
SELECT @Parent, 'Others, Others', 1;


GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Sports');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry, IsUsed)
SELECT @Parent, 'Football', 1, 0 UNION ALL
SELECT @Parent, 'Cricket', 1, 0 UNION ALL
SELECT @Parent, 'Basketball', 1, 0 UNION ALL
SELECT @Parent, 'Badminton', 1, 0 UNION ALL
SELECT @Parent, 'Tennis', 1, 0 UNION ALL
SELECT @Parent, 'Bikes', 1, 0 UNION ALL
SELECT @Parent, 'Camping & Diving', 1, 0 UNION ALL
SELECT @Parent, 'Fitness', 1, 0 UNION ALL
SELECT @Parent, 'Golf', 1, 0 UNION ALL
SELECT @Parent, 'Sport Equipment', 1, 0 UNION ALL
SELECT @Parent, 'Sport Item for Sale (Used)', 1, 1 UNION ALL
SELECT @Parent, 'Sports, Others', 1, 0;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Services');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Mobile Repair', 1 UNION ALL
SELECT @Parent, 'Computer & Laptop Repair', 1 UNION ALL
SELECT @Parent, 'Eletronic Equipment Repair', 1 UNION ALL
SELECT @Parent, 'Beauty Parlor', 1 UNION ALL
SELECT @Parent, 'Advertising & Promotion', 1 UNION ALL
SELECT @Parent, 'Agriculture', 1 UNION ALL
SELECT @Parent, 'Event Management', 1 UNION ALL
SELECT @Parent, 'Health & Fitness', 1 UNION ALL
SELECT @Parent, 'Courier & Delivery', 1 UNION ALL
SELECT @Parent, 'Child Care', 1 UNION ALL
SELECT @Parent, 'Domestic Services', 1 UNION ALL
SELECT @Parent, 'Marketing & Management', 1 UNION ALL
SELECT @Parent, 'Travel & Tour', 1 UNION ALL
SELECT @Parent, 'Home Improvement', 1 UNION ALL
SELECT @Parent, 'Home Mortgage', 1 UNION ALL
SELECT @Parent, 'Home Services', 1 UNION ALL
SELECT @Parent, 'Housekeeping', 1 UNION ALL
SELECT @Parent, 'Landscaping', 1 UNION ALL
SELECT @Parent, 'Shooting & Photography', 1 UNION ALL
SELECT @Parent, 'Maids', 1 UNION ALL
SELECT @Parent, 'Plumbing & Recycling', 1 UNION ALL
SELECT @Parent, 'Wedding Planning & Matrimonial', 1 UNION ALL
SELECT @Parent, 'Vehicle (On Hire or Ticket)', 1 UNION ALL
SELECT @Parent, 'Services, Others', 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Professional');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Legal Advise', 1 UNION ALL
SELECT @Parent, 'Medical Service', 1 UNION ALL
SELECT @Parent, 'Security Service', 1 UNION ALL
SELECT @Parent, 'Construction & Engineering', 1 UNION ALL
SELECT @Parent, 'Consulting & Corporate Services', 1 UNION ALL
SELECT @Parent, 'Banking & Insurance', 1 UNION ALL
SELECT @Parent, 'Web Designing & Hosting', 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Training');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Computer-Animation & Multimedia', 1 UNION ALL
SELECT @Parent, 'Language Classes', 1 UNION ALL
SELECT @Parent, 'Tuition & Coaching Classes', 1 UNION ALL
SELECT @Parent, 'Banking Training', 1 UNION ALL
SELECT @Parent, 'Accounting Classes', 1 UNION ALL
SELECT @Parent, 'Hobby Classes', 1 UNION ALL
SELECT @Parent, 'Workshop', 1 UNION ALL
SELECT @Parent, 'Dance Classes', 1;

GO

DECLARE @Parent integer = (SELECT CategoryId FROM dbo.Categories WHERE CategoryName='Home & Garden');
INSERT INTO dbo.Categories(ParentCategoryId, CategoryName, AllowEntry)
SELECT @Parent, 'Antiques', 1 UNION ALL
SELECT @Parent, 'Arts & Crafts', 1 UNION ALL
SELECT @Parent, 'Bathrooms', 1 UNION ALL
SELECT @Parent, 'Building Materials', 1 UNION ALL
SELECT @Parent, 'Elevators', 1 UNION ALL
SELECT @Parent, 'Candles', 1 UNION ALL
SELECT @Parent, 'Carpet & Rugs', 1 UNION ALL
SELECT @Parent, 'Clocks', 1 UNION ALL
SELECT @Parent, 'Cooking', 1 UNION ALL
SELECT @Parent, 'Decorative', 1 UNION ALL
SELECT @Parent, 'Food & Drink', 1 UNION ALL
SELECT @Parent, 'Kitchen', 1 UNION ALL
SELECT @Parent, 'Lighting', 1 UNION ALL
SELECT @Parent, 'Yard & Garden', 1 UNION ALL
SELECT @Parent, 'Home & Garden, Others', 1;

GO

DECLARE @CategoryId integer = (SELECT CategoryId FROM Categories WHERE CategoryName='Motorbikes (New)');
INSERT INTO dbo.ItemTypes(CategoryId, ItemTypeName, ParentItemTypeId)
SELECT @CategoryId, 'Bajaj Pulsar', NULL UNION ALL
SELECT @CategoryId, 'Bajaj Discover', NULL UNION ALL
SELECT @CategoryId, 'Bajaj Avenger', NULL UNION ALL
SELECT @CategoryId, 'Yamaha Gladiator', NULL;

GO


DECLARE @CategoryId integer = (SELECT CategoryId FROM Categories WHERE CategoryName='Guitars (New)');
INSERT INTO dbo.ItemTypes(CategoryId, ItemTypeName, ParentItemTypeId)
SELECT @CategoryId, 'Hovner', NULL UNION ALL
SELECT @CategoryId, 'Yamaha', NULL UNION ALL
SELECT @CategoryId, 'Gibson', NULL;


GO

INSERT INTO dbo.ItemConditions(ItemCondItionName)
SELECT 'New-Box Packed'				UNION ALL
SELECT 'New-Box Opened'				UNION ALL
SELECT 'Old-Box Packed'				UNION ALL
SELECT 'Used'						UNION ALL
SELECT 'Damanged'					UNION ALL
SELECT 'For Parts Not Working';

GO
INSERT INTO dbo.FieldTypes(FieldTypeName)
SELECT  'Integer Range'									UNION ALL
SELECT  'Integer'										UNION ALL
SELECT  'Money'											UNION ALL
SELECT  'Money Range'									UNION ALL
SELECT  'Text'											UNION ALL
SELECT  'Url'											UNION ALL
SELECT  'Email'											UNION ALL
SELECT  'Memo (Long text)'								UNION ALL
SELECT  'Date'											UNION ALL
SELECT  'Date Range'									UNION ALL
SELECT  'Radiobutton list'								UNION ALL
SELECT  'Combobox List'									UNION ALL
SELECT  'Checkbox List';

GO


DECLARE @CategoryId integer = 0;

WHILE((SELECT MAX(CategoryId) FROM dbo.Categories)!=@CategoryId)
BEGIN
	SET @CategoryId = (SELECT MIN(CategoryId) FROM dbo.Categories WHERE CategoryId>@CategoryId);
	EXECUTE dbo.CreateCategoryForm @CategoryId;
END;

GO
